package com.service.weChatWifiLogin.service.impl;

import com.service.config.constant.Constant;
import com.service.config.utils.*;
import com.service.weChatWifiLogin.dao.*;
import com.service.weChatWifiLogin.dto.*;
import com.service.weChatWifiLogin.entity.*;
import com.service.weChatWifiLogin.exception.NewWifiLoginException;
import com.service.weChatWifiLogin.service.ReviewRecordInfoService;
import com.service.weChatWifiLogin.service.ShopInfoService;
import com.service.weChatWifiLogin.service.VFilePhysicsInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;

import static com.service.weChatWifiLogin.utile.MD5Util.*;
import com.service.config.utils.*;
import com.service.weChatWifiLogin.dao.CustomerOrBossDao;
import com.service.weChatWifiLogin.dao.ShopCustomerDao;
import com.service.weChatWifiLogin.dao.ShopInfoDao;
import com.service.weChatWifiLogin.dto.AddShopInfoDto;
import com.service.weChatWifiLogin.dto.ShopCustomerDto;
import com.service.weChatWifiLogin.dto.ShopInfoDto;
import com.service.weChatWifiLogin.dto.SiteDto;
import com.service.weChatWifiLogin.entity.CustomerOrBoss;
import com.service.weChatWifiLogin.entity.ShopCustomer;
import com.service.weChatWifiLogin.entity.ShopInfo;
import com.service.weChatWifiLogin.entity.VFilePhysicsInfo;
import com.service.weChatWifiLogin.exception.NewWifiLoginException;
import com.service.weChatWifiLogin.service.CustomerOrBossService;
import com.service.weChatWifiLogin.service.ShopInfoService;
import com.service.weChatWifiLogin.service.VFilePhysicsInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

import static com.service.weChatWifiLogin.utile.MD5Util.getCharAndNumr;

/**
 * 店铺表(ShopInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-06-16 17:10:33
 */
@Service("shopInfoService")
@Slf4j
public class ShopInfoServiceImpl implements ShopInfoService {
    @Resource
    private ShopInfoDao shopInfoDao;
    @Resource
    CloudCampusApi cloudCampusApi;
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private ShopCustomerDao shopCustomerDao;
    @Resource
    private CustomerOrBossDao customerOrBossDao;
    @Resource
    private VFilePhysicsInfoService vFilePhysicsInfoService;
    @Resource
    private ShopInfoReviewDao shopInfoReviewDao;
    @Resource
    private ReviewRecordInfoService reviewRecordInfoService;
    @Resource
    private NameListDao nameListDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ShopInfo queryById(String id) {
        return this.shopInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ShopInfo> queryAllByLimit(int offset, int limit) {
        return this.shopInfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param shopInfo 实例对象
     * @return 实例对象
     */
    @Override
    public ShopInfo insert(ShopInfo shopInfo) {
        this.shopInfoDao.insert(shopInfo);
        return shopInfo;
    }

    /**
     * 修改数据
     *
     * @param shopInfo 实例对象
     * @return 实例对象
     */
    @Override
    public ShopInfo update(ShopInfo shopInfo) {
        this.shopInfoDao.update(shopInfo);
        return this.queryById(shopInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public Result deleteById(String id) throws Exception {
        ShopInfo shopInfo1 = shopInfoDao.queryById(id);
        if (shopInfo1 != null) {
            ShopInfo shopInfo = new ShopInfo();
            shopInfo.setId(id);
            shopInfo.setStatus(true);
            shopInfo.setUpdateTime(new Date());
            shopInfoDao.update(shopInfo);
            ShopInfoReview shopInfoReview = ModelMapperUtil.strictMap(shopInfo, ShopInfoReview.class);
            shopInfoReviewDao.update(shopInfoReview);
            ShopInfoDto shopInfoDto = ModelMapperUtil.strictMap(shopInfo1, ShopInfoDto.class);
            if (shopInfoDto.getTenantName() != null && !shopInfoDto.getTenantName().equals("") && shopInfoDto.getTenantPassword() != null
                    && !shopInfoDto.getTenantPassword().equals("") && shopInfoDto.getDomain() != null && !shopInfoDto.getDomain() .equals("")) {
                HttpHeaders token = getToken(shopInfoDto);
                cloudCampusApi.deleteSsId(id,token,shopInfo1.getDomain()); // 操作云管 删除云管上的ssid
                shopInfo.setDomain("naas");
                shopInfo.setTenantPassword("error");
                shopInfo.setTenantName("error");
                shopInfo.setUpdateTime(new Date());
                shopInfoDao.update(shopInfo);
                shopInfoReview = ModelMapperUtil.strictMap(shopInfo, ShopInfoReview.class);
                shopInfoReviewDao.update(shopInfoReview);
                throw new NewWifiLoginException("该华为云管理账号有误请重新校验");
            }
        }
        return Result.ok();
    }
    /**
     * 递归查询缓存中存在验证码
     * @return
     */
    private  String getRandom(){
        String randomNum = CharUtil.getRandomNum(5);
        ShopInfo shopInfo = shopInfoDao.queryBySsIdFlag(randomNum);
        if (shopInfo != null) {
            getRandom();
        }
        return randomNum;
    }

    /**
     * 后台审核完毕，用户操作提交配置下发
     * @param shopInfoDto
     * @return
     */
    @Override
    public Result updateShopInfo(ShopInfoDto shopInfoDto) throws Exception {
        // 校验logo类型
        if (shopInfoDto.getLogoType() == null) {
            shopInfoDto.setLogoType(1);
        }
        if (shopInfoDto.getLogoType()==1) {
            shopInfoDto.setLogoId(shopInfoDto.getLogoId());
        }
        // 校验营销图片类型
        if (shopInfoDto.getMarketingType() == null) {
            shopInfoDto.setMarketingType(1);
        }
        if (shopInfoDto.getMarketingType()==1) {
           shopInfoDto.setMarketingId(shopInfoDto.getMarketingId());
        }
        ShopInfo shopInfo = ModelMapperUtil.strictMap(shopInfoDto, ShopInfo.class);
        shopInfo.setUpdateTime(new Date());
        shopInfoDao.update(shopInfo);
        if (shopInfoDto.getTenantName() != null && !shopInfoDto.getTenantName().equals("") && shopInfoDto.getTenantPassword() != null
                && !shopInfoDto.getTenantPassword().equals("") && shopInfoDto.getDomain() != null && !shopInfoDto.getDomain() .equals("")) {
            HttpHeaders token = getToken(shopInfoDto);
            List<SiteDto> sites = cloudCampusApi.getSites(token, shopInfoDto.getDomain());
            if (sites == null) {
                shopInfoDto.setDomain("naas");
                shopInfoDto.setTenantPassword("error");
                shopInfoDto.setTenantName("error");
                shopInfo = ModelMapperUtil.strictMap(shopInfoDto, ShopInfo.class);
                shopInfo.setUpdateTime(new Date());
                shopInfoDao.update(shopInfo);
                throw new NewWifiLoginException("该华为云管理账号有误请重新校验");
            }
            cloudCampusApi.addSsId(shopInfoDto,sites,token);
        }
        ShopInfoReview shopInfoReview = ModelMapperUtil.strictMap(shopInfoDto, ShopInfoReview.class);
        shopInfoReview.setReviewStatus(Constant.REVIEW_ISSUE);
        shopInfoReview.setReviewStatusDesc("设置成功");
        shopInfoReviewDao.update(shopInfoReview);
        return Result.ok();
    }

    /**
     * 新增店铺
     * @param addShopInfoDto
     * @return
     */
    @Override
    public Result addShopInfo( AddShopInfoDto addShopInfoDto) {
        addShopInfo(ModelMapperUtil.strictMap(addShopInfoDto,ShopInfo.class));
        return Result.ok();
    }

    /**
     * 导出顾客清单
     * @param response
     * @param request
     * @param shopId
     */
    @Override
    public void queryByShopId(HttpServletResponse response, HttpServletRequest request,String shopId) {
        ExcelUtil<ShopCustomerDto> util = new ExcelUtil<>(ShopCustomerDto.class);
        List<ShopCustomer> shopCustomerList = shopCustomerDao.queryByShopId(shopId);
        ShopInfo shopInfo = shopInfoDao.queryById(shopId);
        List<ShopCustomerDto> shopCustomerDtos = ModelMapperUtil.strictMapList(shopCustomerList, ShopCustomerDto.class);
        shopCustomerDtos.forEach(shopCustomerDto -> {
            CustomerOrBoss customerOrBoss = customerOrBossDao.queryById(shopCustomerDto.getCustomerOrBossId());
            shopCustomerDto.setOpenId(customerOrBoss.getOpenId());
            shopCustomerDto.setTelphone(customerOrBoss.getTelphone());
            shopCustomerDto.setShopName(shopInfo.getShopName());
        });
        R r = util.exportExcel(shopCustomerDtos, "顾客清单");
        String fileName = (String) r.get("msg");
        downloadFile(response, request, fileName);
    }

    /**
     * 查询店铺列表（展示审核中的和未做修改的店铺）
     * @param bAuthToken
     * @param bossId
     * @return
     */
    @Override
    public Result queryByBossId(String bAuthToken,String bossId) {
        CustomerOrBoss customerOrBoss = new CustomerOrBoss();
        if (redisUtil.exist(bAuthToken)) {
            customerOrBoss = ModelMapperUtil.strictMap(redisUtil.getValue(bAuthToken), CustomerOrBoss.class);
        }
        if (bossId == null || bossId.equals("")) {
            bossId =  customerOrBoss.getId();
        }
        ShopInfoReview shopInfoReview = new ShopInfoReview();
        shopInfoReview.setCustomerOrBossId(bossId);
        shopInfoReview.setStatus(false);// 店铺未删除标志
        List<ShopInfoReview> shopInfoList = shopInfoReviewDao.queryAll(shopInfoReview);
        customerOrBoss = customerOrBossDao.queryById(bossId);
        customerOrBoss.setScanCount(customerOrBoss.getScanCount()+1);
        customerOrBossDao.update(customerOrBoss); // 更新扫码次数
        shopInfoList.forEach(shopInfo1 -> {
            shopInfo1 = getFileUrl1(shopInfo1);
        });
        return Result.ok().setData(shopInfoList);
    }

    /**
     * boss端提交审核之后，正式表的状态为审核中
     * @param shopInfoDto
     * @return
     */
    @Override
    public Result updateShopInfoConfig(ShopInfoDto shopInfoDto) {
        // 校验logo类型
        if (shopInfoDto.getLogoType() == null) {
            shopInfoDto.setLogoType(1);
        }
        if (shopInfoDto.getLogoType()==1) {
            shopInfoDto.setLogoId(shopInfoDto.getLogoId());
        }
        // 校验营销图片类型
        if (shopInfoDto.getMarketingType() == null) {
            shopInfoDto.setMarketingType(1);
        }
        if (shopInfoDto.getMarketingType()==1) {
            shopInfoDto.setMarketingId(shopInfoDto.getMarketingId());
        }
        ShopInfoReview shopInfoReview = ModelMapperUtil.strictMap(shopInfoDto, ShopInfoReview.class);
        ShopInfoReview shopInfoReview1 = shopInfoReviewDao.queryById(shopInfoReview.getId());
        if (shopInfoReview1 != null) {
            shopInfoReview.setReviewStatus(Constant.REVIEW_TIME);
            shopInfoReview.setReviewStatusDesc("审核中");
            shopInfoReview.setUpdateTime(new Date());
            shopInfoReviewDao.update(shopInfoReview);
        }else {
            shopInfoReview.setReviewStatus(Constant.REVIEW_TIME);
            shopInfoReview.setReviewStatusDesc("审核中");
            shopInfoReview.setUpdateTime(new Date());
            shopInfoReview.setAddTime(new Date());
            shopInfoReviewDao.insert(shopInfoReview);
        }
        if (shopInfoDto.getTenantName() != null && !shopInfoDto.getTenantName().equals("") && shopInfoDto.getTenantPassword() != null
                && !shopInfoDto.getTenantPassword().equals("") && shopInfoDto.getDomain() != null && !shopInfoDto.getDomain() .equals("")) {
            HttpHeaders token = getToken(shopInfoDto);
            List<SiteDto> sites = cloudCampusApi.getSites(token, shopInfoDto.getDomain());
            if (sites == null) {
                shopInfoDto.setDomain("naas");
                shopInfoDto.setTenantPassword("error");
                shopInfoDto.setTenantName("error");
                shopInfoReview.setUpdateTime(new Date());
                shopInfoReviewDao.update(ModelMapperUtil.strictMap(shopInfoDto,ShopInfoReview.class));
                throw new NewWifiLoginException("该华为云管理账号有误请重新校验");
            }
        }
        return Result.ok();
    }

    /**
     * 查询店铺配置信息
     * @param bAuthToken
     * @param shopId
     * @param flag
     * @return
     * @throws Exception
     */
    @Override
    public Result queryShopInfoById(String bAuthToken, String shopId, String flag) throws Exception {
        ShopInfo shopInfo = new ShopInfo();
        if (flag.equals("1")) {
            ShopInfoReview shopInfoReview = shopInfoReviewDao.queryById(shopId);
            if (shopInfoReview != null) {
                shopInfoReview = getFileUrl1(shopInfoReview);
                ShopInfoReviewDto shopInfoReviewDto = ModelMapperUtil.strictMap(shopInfoReview, ShopInfoReviewDto.class);
                shopInfoReviewDto.setComment(JsonXMLUtils.json2obj(shopInfoReview.getComment(),ReviewRecordInfoDto.class));
                return  Result.ok().setData(shopInfoReviewDto);
            }
        }else {
           shopInfo = shopInfoDao.queryById(shopId);
           shopInfo = getFileUrl(shopInfo);
           return  Result.ok().setData(shopInfo);
        }
        HashMap map = new HashMap();
        map.put("errorMsg","店铺不存在");
        map.put("code",10001);
        return  Result.ok().setData(map);
    }

    /**
     * 查询文件路径
     * @param shopInfoReview
     * @return
     */
    private ShopInfoReview getFileUrl1(ShopInfoReview shopInfoReview) {
        if (shopInfoReview.getLogoType() != null) {
            if (shopInfoReview.getLogoType()==0) {
                // 设置logo的url
                if (shopInfoReview.getLogoId() != null) {
                    VFilePhysicsInfo vFilePhysicsInfo = vFilePhysicsInfoService.queryById(shopInfoReview.getLogoId());
                    if (vFilePhysicsInfo != null) {
                        shopInfoReview.setLogoId(getUrl(vFilePhysicsInfo));
                    }
                }
            }
        }
        if (shopInfoReview.getMarketingType() != null) {
            if (shopInfoReview.getMarketingType()==0) { // 设置营销图片的url
                if (shopInfoReview.getMarketingId() != null) {
                    VFilePhysicsInfo vFilePhysicsInfo = vFilePhysicsInfoService.queryById(shopInfoReview.getMarketingId());
                    if (vFilePhysicsInfo != null) {
                        shopInfoReview.setMarketingId(getUrl(vFilePhysicsInfo));
                    }
                }
            }
        }
        return shopInfoReview;
    }

    /**
     * 取消审核
     * @param shopId
     * @return
     */
    @Override
    public Result cancelShopInfoConfig(String shopId) {
        ShopInfoReview shopInfoReview = new ShopInfoReview();
        shopInfoReview.setId(shopId);
        shopInfoReview.setReviewStatus(Constant.REVIEW_WAIT); // boss取消审核 状态改为待提交
        shopInfoReview.setReviewStatusDesc("待提交");
        shopInfoReview.setUpdateTime(new Date());
        shopInfoReviewDao.update(shopInfoReview);
        return Result.ok();
    }

    /**
     * 用户查询审核记录
     * @param shopId
     * @return
     */
    @Override
    public Result queryRecordInfo(String shopId) {
        List<ReviewRecordInfo> reviewRecordInfoList = reviewRecordInfoService.queryAllByShopIdAndLimit(shopId);
        Map<String, List<ReviewRecordInfo>> collect = reviewRecordInfoList.stream().collect(Collectors.groupingBy(ReviewRecordInfo::getVersionNo));
        return Result.ok().setData(collect);
    }

    /**
     * 管理员查询审核记录（筛选）
     * @param shopId
     * @param status
     * @param startDate
     * @param endDate
     * @return
     * @throws ParseException
     */
    @Override
    public Result queryManageRecordInfo(String shopId, Boolean status,String startDate, String endDate,Integer pageSize ,Integer pageNum ) throws ParseException {
        ReviewRecordInfo reviewRecordInfo = new ReviewRecordInfo();
        if (shopId != null && !"".equals(shopId)) {
            reviewRecordInfo.setShopId(shopId);
        }
        if (status != null) {
            if (status){
                reviewRecordInfo.setReviewStatus(Constant.REVIEW_SUCCESS); // 查询审核成功
            }else {
                reviewRecordInfo.setReviewStatus(Constant.REVIEW_FAIL); // 查询审核失败
            }
        }
        if (startDate != null && !"".equals(startDate) && endDate != null && !"".equals(endDate)) {
            reviewRecordInfo.setVersionNo(DateUtil.timeStamp2Date(startDate,""));
            reviewRecordInfo.setReviewerContent(DateUtil.timeStamp2Date(endDate,""));
        }
        return reviewRecordInfoService.queryAll(reviewRecordInfo,pageSize,pageNum);
    }

    /**
     * 校验云管api
     * @param checkTenantDto
     * @return
     */
    @Override
    public Result check(CheckTenantDto checkTenantDto) {
        HttpHeaders token = getToken(ModelMapperUtil.strictMap(checkTenantDto, ShopInfoDto.class));
        List<SiteDto> sites = cloudCampusApi.getSites(token, checkTenantDto.getDomain());
        if (sites == null) {
            throw new NewWifiLoginException("该华为云管理账号有误请重新校验");
        }
        return Result.ok();
    }

    /**
     * 版本回退
     * @param shopId
     * @return
     */
    @Override
    public Result returnShopInfoConfig(String shopId) {
        ShopInfo shopInfo = shopInfoDao.queryById(shopId);
        ShopInfoReview shopInfoReview = ModelMapperUtil.strictMap(shopInfo, ShopInfoReview.class);
        shopInfoReview.setReviewStatus(Constant.REVIEW_CANCEL); // boss版本回退
        shopInfoReview.setReviewStatusDesc("已撤销"); // boss版本回退
        shopInfoReview.setUpdateTime(new Date());
        shopInfoReviewDao.deleteById(shopInfoReview.getId());
        shopInfoReviewDao.insert(shopInfoReview);
        return Result.ok();
    }

    /**
     * 查询黑白名单
     * @param shopId
     * @param type
     * @return
     */
    @Override
    public Result queryUserList(String shopId, Integer type) {
        HashMap map = new HashMap();
        NameList nameList = new NameList();
        nameList.setShopId(shopId);
        nameList.setType(type);
        List<NameList> nameLists = nameListDao.queryAll(nameList);
        List<NameListDto> nameListDtoList = ModelMapperUtil.strictMapList(nameLists, NameListDto.class);
        if (nameListDtoList.size() > 20) {
            map.put("total",20);
            nameListDtoList = nameListDtoList.subList(0, 19);
            map.put("nameListDtoList",nameListDtoList);
        }else {
            map.put("total",nameListDtoList.size());
            map.put("nameListDtoList",nameListDtoList);
        }
        return Result.ok().setData(map);
    }

    /**
     * 配置黑白名单
     * @param shopId
     * @param type
     * @return
     */
    @Override
    @Transactional
    public Result configUserList(String shopId, Integer type) {
        ShopInfoReview shopInfoReview = new ShopInfoReview();
        shopInfoReview.setId(shopId);
        shopInfoReview.setNameListType(type);
        shopInfoReviewDao.update(shopInfoReview);
        ShopInfo shopInfo = ModelMapperUtil.strictMap(shopInfoReview, ShopInfo.class);
        shopInfoDao.update(shopInfo);
        return Result.ok();
    }


    /**
     * 查询文件路径
     * @param shopInfo
     * @return
     */
    private ShopInfo getFileUrl(ShopInfo shopInfo) {
        if (shopInfo.getLogoType() != null) {
            if (shopInfo.getLogoType()==0) {
                // 设置logo的url
                if (shopInfo.getLogoId() != null) {
                    VFilePhysicsInfo vFilePhysicsInfo = vFilePhysicsInfoService.queryById(shopInfo.getLogoId());
                    if (vFilePhysicsInfo != null) {
                        shopInfo.setLogoId(getUrl(vFilePhysicsInfo));
                    }
                }
            }
        }
        if (shopInfo.getMarketingType() != null) {
            if (shopInfo.getMarketingType()==0) { // 设置营销图片的url
                if (shopInfo.getMarketingId() != null) {
                    VFilePhysicsInfo vFilePhysicsInfo = vFilePhysicsInfoService.queryById(shopInfo.getMarketingId());
                    if (vFilePhysicsInfo != null) {
                        shopInfo.setMarketingId(getUrl(vFilePhysicsInfo));
                    }
                }
            }
        }
        return shopInfo;
    }


    /**
     * 获取用户token
     *
     * @param shopInfoDto
     */
    public HttpHeaders getToken(ShopInfoDto shopInfoDto) {

        HttpHeaders requestHeaders = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        requestHeaders.setContentType(type);
        requestHeaders.add("Accept", MediaType.APPLICATION_JSON.toString());

        String userName = shopInfoDto.getTenantName();
        String password = shopInfoDto.getTenantPassword();
        String token = "";
        try {
            if (redisUtil.exist(userName.concat("token"))) {
                token = redisUtil.getValue(userName.concat("token"));
            } else {
                //获取token
                token = cloudCampusApi.getToken(userName, password, requestHeaders, shopInfoDto.getDomain());
                redisUtil.set(userName.concat("token"), 1, token, 10);
            }
            //获取站点
            requestHeaders.add("X-AUTH-TOKEN", token);
            return requestHeaders;
        } catch (Exception e) {
            log.error("token Access failure!");
            return null;
        }
    }

    /**
     * 新增店铺
     * @param shopInfo
     * @param shopInfo
     * @return
     */
    private ShopInfo addShopInfo(ShopInfo shopInfo) {
        shopInfo.setId(IdUtil.getStringId());
        shopInfo.setShopName("店铺的名字"+getCharAndNumr(2));
        shopInfo.setLogoId("https://cloudcampusapps.top/wifilink/logo/028b484fcf0a4f19a681f6b9ee1d3d67.png");
        shopInfo.setLogoType(1);
        shopInfo.setMarketingId("https://cloudcampusapps.top/wifilink/logo/f1a44db2acc54855b801a617ceda3acf.png");
        shopInfo.setMarketingType(1);
        shopInfo.setSsidFlag(getRandom());
        shopInfo.setStatus(false);
        shopInfo.setSsidFlag(getRandom());
        shopInfo.setAddTime(new Date());
        shopInfo.setUpdateTime(new Date());
        shopInfo.setSsidName("wifi的名字"+getCharAndNumr(2));
        shopInfo.setSsidPassword(getCharAndNumr(8));
        shopInfo.setCustomerOrBossId(shopInfo.getCustomerOrBossId());
        shopInfo.setState(1);
        shopInfoDao.insert(shopInfo); // 默认生成空的店铺
        ShopInfoReview shopInfoReview = ModelMapperUtil.strictMap(shopInfo, ShopInfoReview.class);
        shopInfoReviewDao.insert(shopInfoReview);
        return shopInfo;
    }
}
